﻿using EdiNet;
using Xunit;
using System;
using System.IO;

namespace EdiNet.Test
{
    
    
    public class EdiReaderWriterSettingsTest
    {

        /// <summary>
        ///A test for EdiReaderWriterSettings Constructor
        ///</summary>
        [Fact()]
        public void EdiReaderWriterSettingsConstructorTest()
        {
            char dataElementSeparator = 'A'; 
            char repetitionSeparator = 'B'; 
            char componentSeparator = 'C';
            char segmentTerminator = 'D';
            char releaseIndicator = 'E';
            SegmentTerminatorSuffix segmentTerminatorSuffix = SegmentTerminatorSuffix.LF;
            EdiStandard standard = EdiStandard.X12;
            EdiReaderWriterSettings target = EdiReaderWriterSettings.CreateFromChars(DefaultEdiEncoding.Encoding, dataElementSeparator, repetitionSeparator, componentSeparator, segmentTerminator, releaseIndicator, segmentTerminatorSuffix, standard);
            Assert.Equal(target.DataElementSeparatorChar, dataElementSeparator);
            Assert.Equal(target.RepetitionSeparatorChar, repetitionSeparator);
            Assert.Equal(target.ComponentSeparatorChar, componentSeparator);
            Assert.Equal(target.SegmentTerminatorChar, segmentTerminator);
            Assert.Equal(target.Suffix, segmentTerminatorSuffix);
            Assert.Equal(target.Standard, standard);
            Assert.Equal(target.ReleaseIndicatorChar, releaseIndicator);
            
        }

        [Fact()]
        public void IsSeparatorrTest()
        {
            EdiReaderWriterSettings s = EdiReaderWriterSettings.DefaultX12;
            Assert.True(s.IsSeparator(s.DataElementSeparator));
            Assert.True(s.IsSeparator(s.SegmentTerminator));
            Assert.True(s.IsSeparator(s.ComponentSeparator));

            Assert.False(s.IsSeparator(s.RepetitionSeparator));
            Assert.False(s.IsSeparator(s.ReleaseIndicator));
            Assert.False(s.IsSeparator(0x40)); //just random char

            
        }

    }
}
